#include <stdio.h>
#include <stdlib.h>
#include "Item.h"
#include "ST.h"
void main(int argc, char *argv[])
{ 
	int N, maxN = atoi(argv[1]), sw = atoi(argv[2]);
    Key v; Item item;
    STinit(maxN);
    for (N = 0; N < maxN; N++)
      {
        if (sw) v = ITEMrand();
          else if (ITEMscan(&v) == EOF) break;
        if (STsearch(v) != NULLitem) continue;
        key(item) = v;
        STinsert(item); 
      }
    STsort(ITEMshow); printf("\n");
    printf("%d keys ", N);
    printf("%d distinct keys\n", STcount());
}
-----
static Item *st;
static int M = maxKey;
void STinit(int maxN) 
{
	int i;
    st = malloc((M+1)*sizeof(Item));
    for (i = 0; i <= M; i++) 
		st[i] = NULLitem; 
}
int STcount() 
{ 
	int i, N = 0;
    for (i = 0; i < M; i++) 
      if (st[i] != NULLitem) 
		N++;
    return N;
}
void STinsert(Item item)
{ 
	st[key(item)] = item; 
}
Item STsearch(Key v)
{ 
	return st[v]; 
}
void STdelete(Item item)
{ 
	st[key(item)] = NULLitem; 
}
Item STselect(int k)
{ 
	int i;
    for (i = 0; i < M; i++)
      if (st[i] != NULLitem) 
        if (k-- == 0) 
			return st[i]; 
}
void STsort(void (*visit)(Item))
{ 
	int i;
    for (i = 0; i < M; i++)
      if (st[i] != NULLitem) 
		visit(st[i]);
}